package com.qiantu.phone.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.qiantu.phone.R;
import com.qiantu.phone.app.AppAdapter;
import com.qiantu.phone.app.AppApplication;
import com.qiantu.phone.bean.RoomEnvironmentalTypeBean;

/**
 *    author : Android 轮子哥
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2019/09/22
 *    desc   : 房间标签数据列表
 */
public final class EnvironmentalTypeAdapter extends AppAdapter<RoomEnvironmentalTypeBean.EnvironmentalType> {

    public EnvironmentalTypeAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {

        private ViewHolder() {
            super(R.layout.item_environmental_type);
        }

        @Override
        public void onBindView(int position) {
            RoomEnvironmentalTypeBean.EnvironmentalType environmentalType = getItem(position);
            TextView textView = (TextView) itemView;
            textView.setText(environmentalType.getTypeName());
            textView.setCompoundDrawablesWithIntrinsicBounds(AppApplication.getInstance().getThemeDrawable(environmentalType.getTypeIcon()), null, AppApplication.getInstance().getThemeDrawable(R.attr.icon_list_next_normal), null);
        }
    }
}